import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../generated/assets.dart';

class EmptyPlaceholder extends StatelessWidget {
  /// 提示文字
  final String message;

  /// 图片路径，如果为null则使用默认图片
  final String? imagePath;

  /// 图片宽度
  final double imageWidth;

  /// 图片高度
  final double imageHeight;

  /// 文字样式
  final TextStyle? textStyle;

  /// 是否居中显示
  final bool center;

  const EmptyPlaceholder({
    Key? key,
    this.message = '暂无数据',
    this.imagePath,
    this.imageWidth = 120,
    this.imageHeight = 120,
    this.textStyle,
    this.center = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final Widget content = Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        // 图片
        Image.asset(
          imagePath ?? Assets.assetsLogo,
          width: imageWidth,
          height: imageHeight,
        ),
        const SizedBox(height: 16),
        // 提示文字
        Text(
          message,
          style: textStyle ?? TextStyle(
            fontSize: 14,
            color: Colors.grey[600],
          ),
          textAlign: TextAlign.center,
        ),
      ],
    );

    // 如果需要居中显示，则使用Center包装
    if (center) {
      return Center(
        child: content,
      );
    }

    // 否则直接返回内容
    return content;
  }
}